package com.oocl.action.impl;

import java.io.FileInputStream;
import java.util.Comparator;
import java.util.List;

import com.oocl.action.ProcessAction;
import com.oocl.pojo.Customer;
import com.oocl.processor.DataProcessor;
import com.oocl.processor.impl.DataProcessorImpl;
import com.oocl.scanner.impl.ScannerImpl;

/**
 * 入口
 * @author GANAB
 *
 */
public class DataProcessAction extends ProcessAction<StringBuilder>{
	private DataProcessor dp = null;


	public DataProcessAction(Comparator<Customer> comparator, String format) {
		this.setComparator(comparator);
		this.setFormat(format);
	}

	
	public StringBuilder action() throws Exception {
		//加载数据
		this.setScanner(new ScannerImpl(new FileInputStream("data.txt")));
		List<Customer> list = this.getScanner().scan();
		//处理
		dp = new DataProcessorImpl(list, this.getFormat());
		StringBuilder sb = dp.process(this.getComparator());
		if(sb!=null){
			return sb;
		}
		return null;
	}

}
